﻿
namespace AIRO.Devices.RFSigGen
{
    using System;
    using System.Runtime.InteropServices;
    using Ivi.RFSigGen.Interop;
    using System.Text.RegularExpressions;
    using Ivi.ConfigServer.Interop;
    using Ivi.Driver.Interop;
    using System.Text;
    

    [Guid("5782E3A6-402E-48f4-8C53-5E5BFEF69112")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("MyDevices.RFSigGen.hp836xx")]
    public class hp836xx : BasicIviDriverVisa, System.IDisposable, IIviDriver, IIviDriverIdentity, IIviComponentIdentity, IIviDriverOperation, IIviDriverUtility, IIviRFSigGen, IIviRFSigGenRF, IIviRFSigGenSweep, IIviRFSigGenFrequencySweep, IIviRFSigGenALC
    {        
        
        private System.IntPtr _handle;

        private bool _disposed = true;

        ~hp836xx() { Dispose(false); }


        /// <summary>
        /// The initialize function initializes the software connection to the instrument and optionally verifies that instrument is in the system.  In addition, it may perform any necessary actions to place the instrument in its reset state.
        /// </summary>
        /// <param name="Resource_Name">
        /// The instrument's VISA resource description.
        /// 
        /// The default for this instrument is "GPIB0::19::INSTR".  If you change the HPIB address of this instrument, you must change the default resource description as well.
        /// 
        /// </param>
        /// <param name="ID_Query">
        /// If VI_TRUE, perform a revision query to verify that the intrument is the one expected by the driver.
        /// 
        /// If VI_FALSE, do not perform a revision query.
        /// </param>
        /// <param name="Reset_Device">
        /// If VI_TRUE, perform a reset operation while initializing the instrument.
        /// 
        /// If VI_FALSE, do not perform a reset operation.
        /// </param>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle.  This is VI_NULL if an error occurred during the initialization process.
        /// 
        /// </param>
        public hp836xx(string Resource_Name, bool ID_Query, bool Reset_Device)
        {
            int pInvokeResult = PInvoke.init(Resource_Name, System.Convert.ToUInt16(ID_Query), System.Convert.ToUInt16(Reset_Device), out this._handle);
            PInvoke.TestForError(this._handle, pInvokeResult);
            this._disposed = false;
        }

        public hp836xx()
        {

        }

        /// <summary>
        /// This method sets the signal generator's CW frequency
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="CW_Frequency">
        /// New CW frequency, in Hz.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFrequencyCW(double CW_Frequency)
        {
            int pInvokeResult = PInvoke.SetFrequencyCW(this._handle, CW_Frequency);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of signal generator's CW frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="CW_Frequency_Query">
        /// Current CW frequency, in Hz.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFrequencyCW(out double CW_Frequency_Query)
        {
            int pInvokeResult = PInvoke.GetFrequencyCW(this._handle, out CW_Frequency_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the signal generator's center frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Center_Frequency">
        /// New center frequency, in Hz.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFrequencyCenter(double Center_Frequency)
        {
            int pInvokeResult = PInvoke.SetFrequencyCenter(this._handle, Center_Frequency);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of signal generator's center frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Center_Frequency_Query">
        /// Current center frequency, in Hz.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFrequencyCenter(out double Center_Frequency_Query)
        {
            int pInvokeResult = PInvoke.GetFrequencyCenter(this._handle, out Center_Frequency_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the signal generator's frequency span.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Span_Frequency">
        /// New span frequency, in Hz.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFrequencySpan(double Span_Frequency)
        {
            int pInvokeResult = PInvoke.SetFrequencySpan(this._handle, Span_Frequency);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of signal generator's span frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Span_Frequency_Query">
        /// Current span frequency, in Hz..
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFrequencySpan(out double Span_Frequency_Query)
        {
            int pInvokeResult = PInvoke.GetFrequencySpan(this._handle, out Span_Frequency_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the signal generator's start frequency. Start frequency must be less than current stop frequency else stop frequency will be "bumped" up.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Start_Frequency">
        /// New start frequency, in Hz.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFrequencyStart(double Start_Frequency)
        {
            int pInvokeResult = PInvoke.SetFrequencyStart(this._handle, Start_Frequency);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of signal generator's start frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Start_Frequency_Query">
        /// Current start frequency, in Hz.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFrequencyStart(out double Start_Frequency_Query)
        {
            int pInvokeResult = PInvoke.GetFrequencyStart(this._handle, out Start_Frequency_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the signal generator's stop frequency. Stop frequency must be greater than current start frequency else start frequency will be "bumped" down.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Stop_Frequency">
        /// New stop frequency, in Hz.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFrequencyStop(double Stop_Frequency)
        {
            int pInvokeResult = PInvoke.SetFrequencyStop(this._handle, Stop_Frequency);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of signal generator's stop frequency.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Stop_Frequency_Query">
        /// Current stop frequency, in Hz.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFrequencyStop(out double Stop_Frequency_Query)
        {
            int pInvokeResult = PInvoke.GetFrequencyStop(this._handle, out Stop_Frequency_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the number of points in a step sweep. It must have a minimum of 2 points and can be up to the instrument's maximum (801). 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Points">
        /// This is the number of discrete frequency points to be set for a sweep.
        /// 
        /// Range:  2 to 801.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetSweepPoints(short Sweep_Points)
        {
            int pInvokeResult = PInvoke.SetSweepPoints(this._handle, Sweep_Points);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current setting of the number of points for a step sweep.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Points_Query">
        /// The number of points in a step sweep.
        /// 
        /// Range:  2 to 801.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetSweepPoints(out short Sweep_Points_Query)
        {
            int pInvokeResult = PInvoke.GetSweepPoints(this._handle, out Sweep_Points_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the frequency sweep mode of the instrument, were the user selects CW, ramp, step, or list operation. Definitions for these modes:
        /// CW    - single frequency (Continuous Wave)
        /// Ramp  - analog sweep
        /// Step  - digitally stepped sweep
        /// List  - digitally stepped list of frequencies sweep
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Frequency_Sweep_Mode">
        /// This is frequency sweep mode to be set.
        /// 
        /// hp836XX_FREQ_SWEEP_MODE_CW     = CW Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_RAMP   = Ramp Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_STEP   = Step Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_LIST   = List Sweep Mode
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetFreqSweepMode(short Frequency_Sweep_Mode)
        {
            int pInvokeResult = PInvoke.SetFreqSweepMode(this._handle, Frequency_Sweep_Mode);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the frequency sweep mode of the instrument, which can be CW, ramp, step, or list operation.
        /// Definitions for these modes:
        /// CW    - single frequency (Continuous Wave)
        /// Ramp  - analog sweep
        /// Step  - digitally stepped sweep
        /// List  - digitally stepped list of frequencies
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Frequency_Sweep_Mode_Query">
        /// This is the value of the frequency sweep mode as read from the instrument.
        /// 
        /// hp836XX_FREQ_SWEEP_MODE_CW     (0) = CW Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_RAMP  (1)  = Ramp Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_STEP  (2)  = Step Sweep Mode
        /// hp836XX_FREQ_SWEEP_MODE_LIST (3)   = List Sweep Mode
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetFreqSweepMode(out short Frequency_Sweep_Mode_Query)
        {
            int pInvokeResult = PInvoke.GetFreqSweepMode(this._handle, out Frequency_Sweep_Mode_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the instrument current sweep time, in secs. If the desired time is less than the fastest time allowed for the current setup, then the instrument will set the current sweep time to the minimum allowed.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Time">
        /// New instrument sweep time, in secs
        /// 
        /// Sweep time range is 10 msec to 200 sec, but minimum time is determined by current setup (span, points, step vs ramp, dwell).
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetSweepTime(double Sweep_Time)
        {
            int pInvokeResult = PInvoke.SetSweepTime(this._handle, Sweep_Time);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function gets the instrument current sweep time.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Time_Query">
        /// Current instrument sweep time, in secs. 
        /// 
        /// Sweep time range is 10 msec to 200 sec, but minimum time is determined by current setup (span, points, step vs ramp, dwell).
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetSweepTime(out double Sweep_Time_Query)
        {
            int pInvokeResult = PInvoke.GetSweepTime(this._handle, out Sweep_Time_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the sweep continuous mode of the instrument, were the user enables or disables the instrument for continuous sweeping.
        /// 
        /// User still needs to call the function "hp836XX_EnableSweep" to force a sweep to occur.
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Continuous_Mode">
        /// New sweep mode.
        /// 
        /// Continuous sweep operation  = VI_TRUE 
        /// Single sweep operation      = VI_FALSE 
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetSweepContinuousMode(bool Sweep_Continuous_Mode)
        {
            int pInvokeResult = PInvoke.SetSweepContinuousMode(this._handle, System.Convert.ToUInt16(Sweep_Continuous_Mode));
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the sweep continuous mode.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Sweep_Continuous_Mode_Query">
        /// Current sweep continuous mode.
        /// 
        /// Continuous sweep operation  = VI_TRUE (1) 
        /// Single sweep operation      = VI_FALSE (0)
        /// 
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetSweepContinuousMode(out bool Sweep_Continuous_Mode_Query)
        {
            ushort Sweep_Continuous_Mode_QueryAsUShort;
            int pInvokeResult = PInvoke.GetSweepContinuousMode(this._handle, out Sweep_Continuous_Mode_QueryAsUShort);
            Sweep_Continuous_Mode_Query = System.Convert.ToBoolean(Sweep_Continuous_Mode_QueryAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method selects single sweep mode, aborts any sweep in progress and initiates a single sweep at the rate determined by the sweep time function.
        /// If the function is called while the instrument is in the middle of a continuous sweep, the sweep is aborted, the signal generator retraces to the starting point but does not start the sweep. Calling the function a second time will start the sweep.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int EnableSweep()
        {
            int pInvokeResult = PInvoke.EnableSweep(this._handle);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the RF output power.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Output_Power">
        /// New RF output power, in units of dBm.
        /// 
        /// Output power range is dependent on instrument model number and options.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetPower(double Output_Power)
        {
            int pInvokeResult = PInvoke.SetPower(this._handle, Output_Power);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of the RF output power.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Output_Power_Query">
        /// Current RF output power, in dBm.
        /// 
        /// Output power range is dependent on instrument model number and options.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetPower(out double Output_Power_Query)
        {
            int pInvokeResult = PInvoke.GetPower(this._handle, out Output_Power_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the operating state of the signal generator's RF output. Although you can configure and engage various modulations, no signal is available at the RF OUTPUT connector until the state of the RF output is set to ON.
        /// Default state is RF Off.
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Output_Power_On">
        /// New operating state of the signal generator's RF output.
        /// 
        /// RF output power on  = VI_TRUE
        /// RF output power off = VI_FALSE
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetPowerOn(bool Output_Power_On)
        {
            int pInvokeResult = PInvoke.SetPowerOn(this._handle, System.Convert.ToUInt16(Output_Power_On));
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the operating state of the signal generator's RF output (on or off).
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Output_Power_On_Query">
        /// This is the current state of the RF output.
        /// 
        /// VI_TRUE  (1) = RF output power on
        /// VI_FALSE (0) = RF output power off
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetPowerOn(out bool Output_Power_On_Query)
        {
            ushort Output_Power_On_QueryAsUShort;
            int pInvokeResult = PInvoke.GetPowerOn(this._handle, out Output_Power_On_QueryAsUShort);
            Output_Power_On_Query = System.Convert.ToBoolean(Output_Power_On_QueryAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the output attenuation level. Note that when setting the attenuator level 10 dB, the output power level is decreased by 10 dB. Programming an attenuation with this function has an effect of also turning the instrument auto attenuation mode off, similar to calling the  "SetAmplitudeAttenuationAuto" function with the parameter set to VI_FALSE.
        /// Requires instruments with option 001 Step Attenuator.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Amplitude_Attenuation">
        /// New value of the output attenuator, in dB.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetAmplitudeAttenuation(double Amplitude_Attenuation)
        {
            int pInvokeResult = PInvoke.SetAmplitudeAttenuation(this._handle, Amplitude_Attenuation);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the current value of the RF output attenuator.
        /// 
        /// Requires instruments with option 001 Step Attenuator.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Amplitude_Attenuation_Query">
        /// The current RF output attenuator setting.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetAmplitudeAttenuation(out double Amplitude_Attenuation_Query)
        {
            int pInvokeResult = PInvoke.GetAmplitudeAttenuation(this._handle, out Amplitude_Attenuation_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the state of the RF coupling switch.
        /// When RF is coupled, the amplitude level of the ALC is kept to within optimal limits by automatic control of the RF output attenuator.
        /// When uncoupled, the RF output attenuator is set to the value of the "SetAmplitudeAttenuation" function.
        /// Default value is coupled.
        /// Requires instruments with option 001 Step Attenuator.
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Amplitude_Attenuation_Auto">
        /// New operating state of the RF attenuator coupling switch.
        /// 
        /// Coupled (Auto On)    = VI_TRUE
        /// Uncoupled (Auto Off) = VI_FALSE 
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetAmplitudeAttenuationAuto(bool Amplitude_Attenuation_Auto)
        {
            int pInvokeResult = PInvoke.SetAmplitudeAttenuationAuto(this._handle, System.Convert.ToUInt16(Amplitude_Attenuation_Auto));
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the state of the RF attenuator coupling switch.
        /// 
        /// Requires instruments with option 001 Step Attenuator.
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Amplitude_Attenuation_AutoQuery">
        /// The current operating state of the RF attenuator coupling switch.
        /// 
        /// VI_TRUE (1)  = Coupled (Auto on)
        /// VI_FALSE (0) = Uncoupled (Auto Off
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetAmplitudeAttenuationAuto(out bool Amplitude_Attenuation_AutoQuery)
        {
            ushort Amplitude_Attenuation_AutoQueryAsUShort;
            int pInvokeResult = PInvoke.GetAmplitudeAttenuationAuto(this._handle, out Amplitude_Attenuation_AutoQueryAsUShort);
            Amplitude_Attenuation_AutoQuery = System.Convert.ToBoolean(Amplitude_Attenuation_AutoQueryAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function loads the instrument with the power flatness array for applying flatness correction to the RF output power.
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Flatness_Array_Size_Write">
        /// Size of the frequency and power data arrays.
        /// 
        /// Range = 1 to 801 frequency/amplitude pairs.
        /// 
        /// </param>
        /// <param name="Flatness_Frequency_Array">
        /// Array of frequency values, in Hz, at which the power array will be applying flatness correction.
        /// 
        /// Array size can be 1 to 801 values. Number of frequency values must match number of amplitude values.
        /// 
        /// </param>
        /// <param name="Flatness_Power_Array">
        /// Array of power flatness values, in dB.
        /// 
        /// Array size can be 1 to 801 values. Number of amplitude values must match number of frequency values.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetPowerFlatnessValues(short Flatness_Array_Size_Write, double[] Flatness_Frequency_Array, double[] Flatness_Power_Array)
        {
            int pInvokeResult = PInvoke.SetPowerFlatnessValues(this._handle, Flatness_Array_Size_Write, Flatness_Frequency_Array, Flatness_Power_Array);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function gets from the instrument the power flatness array that is used for applying flatness correction to the RF output power.
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Flatness_Array_Size_Max">
        /// Maximum size of the of the frequency and power data arrays passed into function.
        /// 
        /// Range = 1 to 801 frequency/amplitude pairs.
        /// </param>
        /// <param name="Flatness_Array_Size_Read">
        /// Size of the frequency and power flatness arrays read from the instrument.
        /// 
        /// </param>
        /// <param name="Flattness_Frequency_Array_Query">
        /// Array of frequency values, in Hz, at which the power array will be applying flatness correction.
        /// </param>
        /// <param name="Flattness_Power_Array_Query">
        /// Array of power flatness values, in dB.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetPowerFlatnessValues(short Flatness_Array_Size_Max, out short Flatness_Array_Size_Read, double[] Flattness_Frequency_Array_Query, double[] Flattness_Power_Array_Query)
        {
            int pInvokeResult = PInvoke.GetPowerFlatnessValues(this._handle, Flatness_Array_Size_Max, out Flatness_Array_Size_Read, Flattness_Frequency_Array_Query, Flattness_Power_Array_Query);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method sets the operating state of the power flatness correction feature.
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Power_Flatness_State">
        /// New operating state of the power flatness correction feature.
        /// 
        /// Power Flatness Correction On  = VI_TRUE
        /// Power Flatness Correction Off = VI_FALSE 
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int SetPowerFlatnessState(bool Power_Flatness_State)
        {
            int pInvokeResult = PInvoke.SetPowerFlatnessState(this._handle, System.Convert.ToUInt16(Power_Flatness_State));
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This method returns the operating state of the power flatness correction feature.
        /// 
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Power_Flatness_State_Query">
        /// Current operating state of the power flatness correction feature.
        /// 
        /// VI_TRUE  (1) = Power Flatness Correction On
        /// VI_FALSE (0) = Power Flatness Correction Off
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int GetPowerFlatnessState(out bool Power_Flatness_State_Query)
        {
            ushort Power_Flatness_State_QueryAsUShort;
            int pInvokeResult = PInvoke.GetPowerFlatnessState(this._handle, out Power_Flatness_State_QueryAsUShort);
            Power_Flatness_State_Query = System.Convert.ToBoolean(Power_Flatness_State_QueryAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// The reset function places the instrument in a default state. Before issuing this function, it may be necessary to send a device clear to ensure that the instrument can execute a reset.  A device clear can be issued by invoking hp836XX_dcl().
        /// 
        /// Reset does not affect the status system or clear any errors.
        /// 
        /// For the states affected by the reset command, see the instrument manual or refer to the following chart.
        /// 
        /// AM  Depth ? 50%
        /// AM Internal Frequency ? 1 kHz
        /// AM Mode ? Normal
        /// AM Source ? External
        /// AM State ? Off
        /// AM Type ? Linear
        /// 
        /// Calibration Peaking  Auto ? Off
        /// Calibration Power Attenuation ?  0 Dbm
        /// Calibration Power Range ? 1
        /// Calibration Span Auto ? Off
        /// 
        /// Correction Array ? Clear
        /// Correction State ? Off
        /// 
        /// Display State ? On
        /// 
        /// FM Deviation ? 1 MHz
        /// FM Coupling  ? AC
        /// FM Filter Hpass ? Maximum
        /// FM Internal  Frequency ? 1 MHz
        /// FM Sensitivity ? Maximum
        /// FM Source ? External
        /// FM State ? Off
        /// 
        /// Frequency Center ? (MAX+MIN) /2
        /// Frequency CW ? (MAX+MIN) /2
        /// Frequency CW Auto ? Off
        /// Frequency Manual ? (MAX+MIN) /2
        /// Frequency Mode ? CW
        /// Frequency Multiplier - 1
        /// Frequency Multiplier State - Off
        /// Frequency Offset ? 0
        /// Frequency Offset State ? Off
        /// Frequency Start ? Minimum
        /// Frequency Step ? Calculated from Span
        /// Frequency Stop Auto ? On
        /// Frequency  Stop ? Maximum
        /// 
        /// Initiate Continuous ? Off
        /// 
        /// List Dwell ? 100 us (minimum)
        /// List Frequency ? (Max+Min) /2
        /// List Manual ? 1
        /// List Mode ? Auto
        /// List Power Correction ? 0
        /// List Trigger Source ? Immediate
        /// 
        /// Marker [n] Amplitude State ? Off
        /// Marker [n] Amplitude Value ? 2 dBm
        /// Marker [n] Frequency ? same as Frequency Center  preset value
        /// Marker [n] Frequency Mode ? Frequency
        /// Marker [n] State ? Off
        /// 
        /// Power ALC Bandwith Auto ? On
        /// Power ALC Correction Factor ? 16 dBm
        /// Power Amplifier State Auto ? On
        /// Power Attenuation Auto ? On
        /// Power Center ? 0 dBm
        /// Power Level ? 0 dBm
        /// Power Mode ? Fixed
        /// Power Slope ? 0
        /// Power Slope State ? Off
        /// Power Span ? 0 dB
        /// Power Start ? 0 dBm
        /// Power State ? Off
        /// Power Step Auto ? On
        /// Power Step Increment ? 10 dB
        /// Power Stop ? 0 dBm
        /// 
        /// Pulse Frequency ? 500 kHz
        /// Pulse Period ? 2 us
        /// Pulse Width ? 1 us
        /// 
        /// Pulse Modulation  External Delay ? Minimum
        /// Pulse Modulation  External Polarity ? Normal
        /// Pulse Modulation  Internal Delay ? 0
        /// Pulse Modulation  Internal Frequency ? 500 kHz
        /// Pulse Modulation  Internal Gate ? Off
        /// Pulse Modulation  Internal Period ? 2 us
        /// Pulse Modulation  Internal Trigger Source ? Internal
        /// Pulse Modulation  Internal Width ? 1 us
        /// Pulse Modulation  Slew ? Minimum
        /// Pulse Modulation  Slew Auto ? On
        /// Pulse Modulation  Source ? Internal
        /// Pulse Modulation  State ? Off
        /// 
        /// Reference Ocillator Source Auto ? On
        /// 
        /// Sweep Dwell ? 100 us
        /// Sweep Dwell Auto ? Off
        /// Sweep Points ? 11
        /// Sweep Step  ?  (StopMAX-StartMIN) /10
        /// Sweep Time ? Minimum
        /// Sweep Time Auto ? On
        /// Sweep Time Limit ? 10 ms
        /// Sweep   Generation ? Analog
        /// Sweep Mode ? Auto
        /// Sweep Manual Point ? 1
        /// Sweep Manual Relative ? 0.50
        /// Sweep Marker State ? Off
        /// System Alternate ? 1
        /// System Alternate State ? Off
        /// System Communicate GPIB Address ? 19
        /// System Millimeter Head Select Auto ? On
        /// System Security Count ? 1
        /// Units AM  ?  Percent 
        /// Units Power ? dBm
        ///  
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int reset()
        {
            int pInvokeResult = PInvoke.reset(this._handle);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// The self-test function causes the instrument to perform a self-test and returns the result of that self-test.  This is used to verify that an instrument is operating properly.  A failure may indicate a potential hardware problem.
        /// 
        /// For a list of possible self-test errors, consult the instrument manual.
        /// </summary>
        /// <param name="Instrument__Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Self_Test_Result">
        /// This is the numeric result from the self-test operation.
        /// 
        /// 0 = no error ( test passed)
        /// </param>
        /// <param name="Self_Test_Message">
        /// The Self-Test status message is limited to 256 characters.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int self_test(out short Self_Test_Result, System.Text.StringBuilder Self_Test_Message)
        {
            int pInvokeResult = PInvoke.self_test(this._handle, out Self_Test_Result, Self_Test_Message);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function returns the error numbers and corresponding error messages in the error queue of an instrument.  See the manual for a listing of the instrument error numbers and messages.
        /// 
        /// Instrument errors may occur when a user attempts to place the instrument in an invalid state such as sending an invalid sequence of coupled commands.
        /// 
        /// Instrument errors can be detected by polling.  Automatic polling can be accomplished by using the hp836XXX_errorQueryDetect() function.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Error_Code">
        /// This is the instrument's error code.
        /// </param>
        /// <param name="Error_Message">
        /// This is the instrument's error message.  It is limited to 256 characters.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int error_query(out int Error_Code, System.Text.StringBuilder Error_Message)
        {
            int pInvokeResult = PInvoke.error_query(this._handle, out Error_Code, Error_Message);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function returns the revision of the instrument driver and the firmware of the instrument being used.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Instrument_Driver_Revision">
        /// Instrument driver revision.  This is limited to 256 characters.
        /// 
        /// Revision format - "A.01.00"
        /// </param>
        /// <param name="Firmware_Revision">
        /// Instrument firmware revision.  This is limited to 256 characters.
        /// 
        /// Revision format - "DD MMM YY", where DD is two numbers for day, MMM is three characters for month, and YY is last two numbers of year.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int revision_query(System.Text.StringBuilder Instrument_Driver_Revision, System.Text.StringBuilder Firmware_Revision)
        {
            int pInvokeResult = PInvoke.revision_query(this._handle, Instrument_Driver_Revision, Firmware_Revision);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// The timeout function sets the timeout value for driver I/O transactions in milliseconds. The timeout period may vary on computer platforms.
        /// 
        /// The default timeout period varies by VISA implementation.
        /// 
        /// Some implementations of VISA will only accept a limited number of timeout values.  If you set the VISA timeout to a given value using one of those implementations, and then query the timeout, you may find that the query returns a different value than the one you set.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Set_Time_Out">
        /// This value sets the I/O timeout for all functions in the driver. It is specified in milliseconds. 
        /// 
        /// MAX = hp836XX_TIMEOUT_MAX   2147483647
        /// MIN = hp836XX_TIMEOUT_MIN   0
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int timeOut(int Set_Time_Out)
        {
            int pInvokeResult = PInvoke.timeOut(this._handle, Set_Time_Out);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// The timeout query function returns the timeout value for driver I/O transactions in milliseconds.  The timeout period may vary on computer platforms.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Time_Out">
        /// This value sets the I/O timeout for all functions in the driver. It is specified in milliseconds.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int timeOut_Q(out int Time_Out)
        {
            int pInvokeResult = PInvoke.timeOut_Q(this._handle, out Time_Out);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function enables or disables automatic instrument error checking.
        /// 
        /// When automatic instrument error querying is enabled, the driver will query the instrument for an error before returning from each driver function.  This adds the overhead of one instrument query to each dirver function call.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Set_Error_Query_Detect">
        /// A boolean which enables/disables automatic instrument error querying.  
        /// 
        /// If VI_TRUE, enable automatic instrument error querying.
        /// 
        /// If VI_FALSE, disable automatic instrument error querying.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int errorQueryDetect(bool Set_Error_Query_Detect)
        {
            int pInvokeResult = PInvoke.errorQueryDetect(this._handle, System.Convert.ToUInt16(Set_Error_Query_Detect));
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function indicates if automatic instrument error detection is enabled or disabled. 
        /// 
        /// When automatic instrument error querying is enabled, the driver will query the instrument for an error before returning from each driver function.  This adds the overhead of one instrument query to each driver function call.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Error_Query_Detect">
        /// A boolean which indicates if automatic instrument error querying is enabled or disabled.  
        /// 
        /// If VI_TRUE, automatic instrument error querying is enabled.
        /// 
        /// If VI_FALSE, automatic instrument error querying is disabled.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int errorQueryDetect_Q(out bool Error_Query_Detect)
        {
            ushort Error_Query_DetectAsUShort;
            int pInvokeResult = PInvoke.errorQueryDetect_Q(this._handle, out Error_Query_DetectAsUShort);
            Error_Query_Detect = System.Convert.ToBoolean(Error_Query_DetectAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function sends a device clear (DCL) to the instrument.
        /// 
        /// A device clear will abort the current operation and enable the instrument to accept a new command or query.
        /// 
        /// This is particularly useful in situations where it is not possible to determine the instrument state. In this case, it is customary to send a device clear before issuing a new instrument driver function.  The device clear ensures that the instrument will be able to begin processing the new commands.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int dcl()
        {
            int pInvokeResult = PInvoke.dcl(this._handle);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function sends the *OPC? command to the instrument and returns VI_TRUE when all pending operations are complete.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Instrument_Ready">
        /// If VI_TRUE, all instrument operations are complete.
        /// 
        /// If VI_FALSE, instrument operations are still pending.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int opc_Q(out bool Instrument_Ready)
        {
            ushort Instrument_ReadyAsUShort;
            int pInvokeResult = PInvoke.opc_Q(this._handle, out Instrument_ReadyAsUShort);
            Instrument_Ready = System.Convert.ToBoolean(Instrument_ReadyAsUShort);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function queries the status byte register and returns the contents of it.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="StatusByte">
        /// This is the value of the status byte.
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int readStatusByte_Q(out short StatusByte)
        {
            int pInvokeResult = PInvoke.readStatusByte_Q(this._handle, out StatusByte);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function queries the operation event register.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Operation_Event_Register">
        /// The value of the operation event register.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int operEvent_Q(out int Operation_Event_Register)
        {
            int pInvokeResult = PInvoke.operEvent_Q(this._handle, out Operation_Event_Register);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function queries the operation condition register.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Operation_Condition_Register">
        /// The value of the operation condition register.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int operCond_Q(out int Operation_Condition_Register)
        {
            int pInvokeResult = PInvoke.operCond_Q(this._handle, out Operation_Condition_Register);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function queries the questionable event register.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Questionable_Event_Register">
        /// The value of the questionable event register.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int quesEvent_Q(out int Questionable_Event_Register)
        {
            int pInvokeResult = PInvoke.quesEvent_Q(this._handle, out Questionable_Event_Register);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function queries the questionable condition register.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Questionable_Condition_Register">
        /// The value of the questionable condition register.
        ///  
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message() function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int quesCond_Q(out int Questionable_Condition_Register)
        {
            int pInvokeResult = PInvoke.quesCond_Q(this._handle, out Questionable_Condition_Register);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function sends a SCPI command to the instrument.  The function does not expect any response.
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Send_String_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmd(string Send_String_Command)
        {
            int pInvokeResult = PInvoke.cmd(this._handle, Send_String_Command);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function sends a SCPI command string to the instrument, and waits for a response which must be a string (character data).
        /// 
        /// A max of size-1 bytes will be read from the instrument into the string and the string will be NULL terminated.
        /// 
        /// If more than size-1 bytes are generated by the instrument then remaining bytes will be discarded and the instrument's output buffer will be cleared.
        ///  
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Query_String_Command">
        /// This is the instrument command.  It must be a NULL termianted C string and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="String_Size">
        /// This is the size of the char array (result) passed to the function to hold the string returned by the instrument.
        /// 
        /// Range:  MIN = 1
        ///         MAX = 2147483647
        /// 
        /// </param>
        /// <param name="String_Result">
        /// The string returned by the instrument.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdString_Q(string Query_String_Command, int String_Size, System.Text.StringBuilder String_Result)
        {
            int pInvokeResult = PInvoke.cmdString_Q(this._handle, Query_String_Command, String_Size, String_Result);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function passes the string in cmd_str followed by a space and then an integer.  Note that either a ViInt16 or 32 can be passed, as the ViInt16 will be promoted.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Send_Integer_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="Send_Integer">
        /// The integer to be appended to the command string. 
        /// 
        /// MIN = hp836XX_CMDINT_MIN   -2147483647
        /// MAX = hp836XX_CMDINT_MAX    2147483647
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdInt(string Send_Integer_Command, int Send_Integer)
        {
            int pInvokeResult = PInvoke.cmdInt(this._handle, Send_Integer_Command, Send_Integer);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// Passes the command string to the instrument.  The function expects a 16-bit integer response from the instrument.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Query_I16_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="I16_Result">
        /// The response from the instrument.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require attention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdInt16_Q(string Query_I16_Command, out short I16_Result)
        {
            int pInvokeResult = PInvoke.cmdInt16_Q(this._handle, Query_I16_Command, out I16_Result);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// Passes the command string to the instrument.  The function expects a 32-bit integer response from the instrument.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Query_I32_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="I32_Result">
        /// The response from the instrument.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdInt32_Q(string Query_I32_Command, out int I32_Result)
        {
            int pInvokeResult = PInvoke.cmdInt32_Q(this._handle, Query_I32_Command, out I32_Result);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// This function passes the string in cmd_str followed by a space and then a real.  Note that either a ViReal32 or 64 can be passed as the ViReal32 will be promoted.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// [INPUT PARAMETER]
        /// 
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Send_Real_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="Send_Real">
        /// The real number to be appended to the command string. 
        /// 
        /// MAX = hp836XX_CMDREAL_MAX    1E+300
        /// MIN = hp836XX_CMDREAL_MIN   -1E+300
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdReal(string Send_Real_Command, double Send_Real)
        {
            int pInvokeResult = PInvoke.cmdReal(this._handle, Send_Real_Command, Send_Real);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        /// <summary>
        /// Passes the command string to the instrument.  The function expects a 64-bit real response from the instrument.
        /// 
        /// </summary>
        /// <param name="Instrument_Handle">
        /// The instrument's VISA session handle returned from hp836XX_init().
        /// 
        /// </param>
        /// <param name="Query_Real_Command">
        /// This is the instrument command.  It must be a NULL terminated C string, and may not exceed 256 bytes in length.
        /// 
        /// </param>
        /// <param name="Real_Result">
        /// The response from the instrument.
        /// 
        /// </param>
        /// <returns>
        /// The meaning of the VISA status returned by the function is as follows:
        /// 
        ///  = 0  "VI_SUCCESS"    The function completed successfully.
        ///  &gt; 0  Warning         The function completed, but an
        ///                       exceptional condition occurred which
        ///                       may require atention.
        ///  &lt; 0  Error           The function did not complete
        ///                       successfully.
        /// 
        /// Use the hp836XX_error_message function to get a textual description of errors and warnings.
        /// 
        /// </returns>
        public int cmdReal64_Q(string Query_Real_Command, out double Real_Result)
        {
            int pInvokeResult = PInvoke.cmdReal64_Q(this._handle, Query_Real_Command, out Real_Result);
            PInvoke.TestForError(this._handle, pInvokeResult);
            return pInvokeResult;
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        public void Initialize(string ResourceName, bool IdQuery, bool Reset, string OptionString)
        {
            if (!_initialized)
            {
                _rangeCheck = true;
                _cache = true;
                _queryInstrumentStatus = false;
                _simulate = false;
                _driverSetup = "";
                _recordCoercions = false;
                _interchangeCheck = false;                

                
                
                string addressStringGrammar = @"(VXI\d*(::\.+(::INSTR)?)|(::MEMACC)|((::\.+)?::BACKPLANE)|(::SERVANT))|(GPIB-VXI\d*(::\.+(::INSTR)?)|(::MEMACC)|((::\.+)?::BACKPLANE))|(GPIB\d*::(\.+(::\.+)?(::INSTR)?)|(INTFC)|(SERVANT))|(ASRL\d*(::INSTR)?)|(TCPIP\d*((::\.+)?::SERVANT)|(::\.+(::\.+)?(::INSTR)?)|(::\.+::\d+::SOCKET))|(USB\d*::\.+::\.+::\.+(::\.+)?(::INSTR)?)|(PXI\d*(::\.+(::\.+)?(::INSTR)?)|(::\d+-\d+(.function)?(::INSTR)?)|(::CHASSIS\d+::SLOT\d+(::FUNC\.+)?(::INSTR)?)|(::MEMACC))";
                Regex addressStringGrammarRegex = new Regex(addressStringGrammar, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (addressStringGrammarRegex.IsMatch(ResourceName))
                {
                    #region VisaResourceName
                    resourceName = ResourceName;

                    int pInvokeResult = PInvoke.init(ResourceName, System.Convert.ToUInt16(IdQuery), System.Convert.ToUInt16(Reset), out this._handle);
                    PInvoke.TestForError(this._handle, pInvokeResult);
                    this._disposed = false;

                    #endregion
                }
                else
                {
                    #region ResourceName is LogicalName
                    _logicalName = ResourceName;
                    IviDriverSession iviSession = ReadConfigStore();
                    try
                    {
                        int pInvokeResult = PInvoke.init(resourceName, System.Convert.ToUInt16(IdQuery), System.Convert.ToUInt16(Reset), out this._handle);
                        PInvoke.TestForError(this._handle, pInvokeResult);
                        this._disposed = false;
                    }
                    catch (InvalidCastException)
                    {
                        throw new Exception("Resource selected must be a message-based session");
                    }
                    catch (Exception exp)
                    {
                        throw;
                    }
                                       
                    #endregion
                }
                ParseOptionString(OptionString);
                _initialized = true;
            }
            else
            {
                iviDriverErrorQueue.Enqueue(new Error(IviDriver_ErrorCodes.E_IVI_ALREADY_INITIALIZED));
            }
        }
        public override void Reset()
        {
            reset();
        }

        public override void SelfTest(ref int TestResult, ref string TestMessage)
        {
            short testRes;
            StringBuilder testMessage=new StringBuilder();
            self_test(out testRes, testMessage);
            TestResult = testRes;
            TestMessage = testMessage.ToString();            
        }

        public override void ErrorQuery(ref int ErrorCode, ref string ErrorMessage)
        {
            StringBuilder errMess = new StringBuilder();
            error_query(out ErrorCode, errMess);
            ErrorMessage = errMess.ToString();
        }

        public override string InstrumentFirmwareRevision
        {
            get
            {
                StringBuilder driverRev=new StringBuilder();
                StringBuilder firmwareRev=new StringBuilder();
                revision_query(driverRev, firmwareRev);
                return firmwareRev.ToString();
            }
        }

        public override string Revision
        {
            get
            {
                StringBuilder driverRev = new StringBuilder();
                StringBuilder firmwareRev = new StringBuilder();
                revision_query(driverRev, firmwareRev);
                return driverRev.ToString();
            }
        }

        public override bool QueryInstrumentStatus
        {
            get
            {
                bool res;
                errorQueryDetect_Q(out res);
                return res;
            }
            set
            {
                errorQueryDetect(value);
            }
        }

        public override void Close()
        {
            this.SetPowerOn(false);
            _initialized = false;
            this.Dispose();
        }

        public void Disable()
        {
            this.SetPowerOn(false);
        }

        private void Dispose(bool disposing)
        {
            if ((this._disposed == false))
            {
                PInvoke.close(this._handle);
                this._handle = System.IntPtr.Zero;
            }
            this._disposed = true;
        }

        private class PInvoke
        {

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_init", CallingConvention = CallingConvention.StdCall)]
            public static extern int init(string Resource_Name, ushort ID_Query, ushort Reset_Device, out System.IntPtr Instrument_Handle);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFrequencyCW", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFrequencyCW(System.IntPtr Instrument_Handle, double CW_Frequency);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFrequencyCW", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFrequencyCW(System.IntPtr Instrument_Handle, out double CW_Frequency_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFrequencyCenter", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFrequencyCenter(System.IntPtr Instrument_Handle, double Center_Frequency);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFrequencyCenter", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFrequencyCenter(System.IntPtr Instrument_Handle, out double Center_Frequency_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFrequencySpan", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFrequencySpan(System.IntPtr Instrument_Handle, double Span_Frequency);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFrequencySpan", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFrequencySpan(System.IntPtr Instrument_Handle, out double Span_Frequency_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFrequencyStart", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFrequencyStart(System.IntPtr Instrument_Handle, double Start_Frequency);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFrequencyStart", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFrequencyStart(System.IntPtr Instrument_Handle, out double Start_Frequency_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFrequencyStop", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFrequencyStop(System.IntPtr Instrument_Handle, double Stop_Frequency);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFrequencyStop", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFrequencyStop(System.IntPtr Instrument_Handle, out double Stop_Frequency_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetSweepPoints", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetSweepPoints(System.IntPtr Instrument_Handle, short Sweep_Points);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetSweepPoints", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetSweepPoints(System.IntPtr Instrument_Handle, out short Sweep_Points_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetFreqSweepMode", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetFreqSweepMode(System.IntPtr Instrument_Handle, short Frequency_Sweep_Mode);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetFreqSweepMode", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetFreqSweepMode(System.IntPtr Instrument_Handle, out short Frequency_Sweep_Mode_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetSweepTime", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetSweepTime(System.IntPtr Instrument_Handle, double Sweep_Time);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetSweepTime", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetSweepTime(System.IntPtr Instrument_Handle, out double Sweep_Time_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetSweepContinuousMode", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetSweepContinuousMode(System.IntPtr Instrument_Handle, ushort Sweep_Continuous_Mode);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetSweepContinuousMode", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetSweepContinuousMode(System.IntPtr Instrument_Handle, out ushort Sweep_Continuous_Mode_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_EnableSweep", CallingConvention = CallingConvention.StdCall)]
            public static extern int EnableSweep(System.IntPtr Instrument_Handle);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetPower", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetPower(System.IntPtr Instrument_Handle, double Output_Power);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetPower", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetPower(System.IntPtr Instrument_Handle, out double Output_Power_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetPowerOn", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetPowerOn(System.IntPtr Instrument_Handle, ushort Output_Power_On);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetPowerOn", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetPowerOn(System.IntPtr Instrument_Handle, out ushort Output_Power_On_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetAmplitudeAttenuation", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetAmplitudeAttenuation(System.IntPtr Instrument_Handle, double Amplitude_Attenuation);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetAmplitudeAttenuation", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetAmplitudeAttenuation(System.IntPtr Instrument_Handle, out double Amplitude_Attenuation_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetAmplitudeAttenuationAuto", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetAmplitudeAttenuationAuto(System.IntPtr Instrument_Handle, ushort Amplitude_Attenuation_Auto);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetAmplitudeAttenuationAuto", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetAmplitudeAttenuationAuto(System.IntPtr Instrument_Handle, out ushort Amplitude_Attenuation_AutoQuery);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetPowerFlatnessValues", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetPowerFlatnessValues(System.IntPtr Instrument_Handle, short Flatness_Array_Size_Write, double[] Flatness_Frequency_Array, double[] Flatness_Power_Array);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetPowerFlatnessValues", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetPowerFlatnessValues(System.IntPtr Instrument_Handle, short Flatness_Array_Size_Max, out short Flatness_Array_Size_Read, [In, Out] double[] Flattness_Frequency_Array_Query, [In, Out] double[] Flattness_Power_Array_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_SetPowerFlatnessState", CallingConvention = CallingConvention.StdCall)]
            public static extern int SetPowerFlatnessState(System.IntPtr Instrument_Handle, ushort Power_Flatness_State);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_GetPowerFlatnessState", CallingConvention = CallingConvention.StdCall)]
            public static extern int GetPowerFlatnessState(System.IntPtr Instrument_Handle, out ushort Power_Flatness_State_Query);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_reset", CallingConvention = CallingConvention.StdCall)]
            public static extern int reset(System.IntPtr Instrument_Handle);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_self_test", CallingConvention = CallingConvention.StdCall)]
            public static extern int self_test(System.IntPtr Instrument__Handle, out short Self_Test_Result, System.Text.StringBuilder Self_Test_Message);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_error_query", CallingConvention = CallingConvention.StdCall)]
            public static extern int error_query(System.IntPtr Instrument_Handle, out int Error_Code, System.Text.StringBuilder Error_Message);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_revision_query", CallingConvention = CallingConvention.StdCall)]
            public static extern int revision_query(System.IntPtr Instrument_Handle, System.Text.StringBuilder Instrument_Driver_Revision, System.Text.StringBuilder Firmware_Revision);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_timeOut", CallingConvention = CallingConvention.StdCall)]
            public static extern int timeOut(System.IntPtr Instrument_Handle, int Set_Time_Out);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_timeOut_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int timeOut_Q(System.IntPtr Instrument_Handle, out int Time_Out);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_errorQueryDetect", CallingConvention = CallingConvention.StdCall)]
            public static extern int errorQueryDetect(System.IntPtr Instrument_Handle, ushort Set_Error_Query_Detect);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_errorQueryDetect_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int errorQueryDetect_Q(System.IntPtr Instrument_Handle, out ushort Error_Query_Detect);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_dcl", CallingConvention = CallingConvention.StdCall)]
            public static extern int dcl(System.IntPtr Instrument_Handle);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_opc_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int opc_Q(System.IntPtr Instrument_Handle, out ushort Instrument_Ready);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_readStatusByte_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int readStatusByte_Q(System.IntPtr Instrument_Handle, out short StatusByte);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_operEvent_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int operEvent_Q(System.IntPtr Instrument_Handle, out int Operation_Event_Register);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_operCond_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int operCond_Q(System.IntPtr Instrument_Handle, out int Operation_Condition_Register);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_quesEvent_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int quesEvent_Q(System.IntPtr Instrument_Handle, out int Questionable_Event_Register);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_quesCond_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int quesCond_Q(System.IntPtr Instrument_Handle, out int Questionable_Condition_Register);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmd", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmd(System.IntPtr Instrument_Handle, string Send_String_Command);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdString_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdString_Q(System.IntPtr Instrument_Handle, string Query_String_Command, int String_Size, System.Text.StringBuilder String_Result);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdInt", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdInt(System.IntPtr Instrument_Handle, string Send_Integer_Command, int Send_Integer);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdInt16_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdInt16_Q(System.IntPtr Instrument_Handle, string Query_I16_Command, out short I16_Result);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdInt32_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdInt32_Q(System.IntPtr Instrument_Handle, string Query_I32_Command, out int I32_Result);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdReal", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdReal(System.IntPtr Instrument_Handle, string Send_Real_Command, double Send_Real);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_cmdReal64_Q", CallingConvention = CallingConvention.StdCall)]
            public static extern int cmdReal64_Q(System.IntPtr Instrument_Handle, string Query_Real_Command, out double Real_Result);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_close", CallingConvention = CallingConvention.StdCall)]
            public static extern int close(System.IntPtr Instrument_Handle);

            [DllImport("hp836XX_32.dll", EntryPoint = "hp836XX_error_message", CallingConvention = CallingConvention.StdCall)]
            public static extern int error_message(System.IntPtr Instrument_Handle, int Status_Code, System.Text.StringBuilder Message);


            public static int TestForError(System.IntPtr handle, int status)
            {
                if ((status < 0))
                {
                    PInvoke.ThrowError(handle, status);
                }
                return status;
            }

            public static int ThrowError(System.IntPtr handle, int code)
            {
                System.Text.StringBuilder msg = new System.Text.StringBuilder(256);
                PInvoke.error_message(handle, code, msg);
                throw new System.Runtime.InteropServices.ExternalException(msg.ToString(), code);
            }
        }



        #region IIviRFSigGen Members

        public IIviRFSigGenALC ALC
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenAnalogModulation AnalogModulation
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenDigitalModulation DigitalModulation
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenIQ IQ
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenLFGenerator LFGenerator
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenPulseGenerator PulseGenerator
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenPulseModulation PulseModulation
        {
            get { throw new NotImplementedException(); }
        }

        public IIviRFSigGenRF RF
        {
            get { return (IIviRFSigGenRF)this; }
        }

        public IIviRFSigGenReferenceOscillator ReferenceOscillator
        {
            get { throw new NotImplementedException(); }
        }

        public void SendSoftwareTrigger()
        {
            throw new NotImplementedException();
        }

        public IIviRFSigGenSweep Sweep
        {
            get { return (IIviRFSigGenSweep)this; }
        }

        #endregion

        #region IIviRFSigGenRF Members

        void IIviRFSigGenRF.Configure(double Frequency, double PowerLevel)
        {
            SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
            SetFrequencyCW(Frequency);
            SetPower(PowerLevel);
        }

        void IIviRFSigGenRF.DisableAllModulation()
        {
            SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
        }

        double IIviRFSigGenRF.Frequency
        {
            get
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                double res;
                GetFrequencyCW(out res);
                return res;
            }
            set
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                SetFrequencyCW(value);
            }
        }

        bool IIviRFSigGenRF.IsSettled()
        {
            SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
            throw new NotImplementedException();
        }

        double IIviRFSigGenRF.Level
        {
            get
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                double res;
                GetPower(out res);
                return res;
            }
            set
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                SetPower(value);
            }
        }

        bool IIviRFSigGenRF.OutputEnabled
        {
            get
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                bool res;
                GetPowerOn(out res);
                return res;
            }
            set
            {
                SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                SetPowerOn(value);
            }
        }

        void IIviRFSigGenRF.WaitUntilSettled(int MaxTimeMilliseconds)
        {
            SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
            throw new NotImplementedException();
        }

        #endregion

        #region IIviRFSigGenFrequencySweep Members

        void IIviRFSigGenFrequencySweep.ConfigureCenterSpan(double Center, double Span)
        {
            SetFrequencyCenter(Center);
            SetFrequencySpan(Span);
        }

        void IIviRFSigGenFrequencySweep.ConfigureStartStop(double Start, double Stop)
        {
            SetFrequencyStart(Start);
            SetFrequencyStop(Stop);
        }

        double IIviRFSigGenFrequencySweep.Start
        {
            get
            {
                double res;
                GetFrequencyStart(out res);
                return res;
            }
            set
            {
                SetFrequencyStart(value);
            }
        }

        double IIviRFSigGenFrequencySweep.Stop
        {
            get
            {
                double res;
                GetFrequencyStop(out res);
                return res;
            }
            set
            {
                SetFrequencyStop(value);
            }
        }

        double IIviRFSigGenFrequencySweep.Time
        {
            get
            {
                double res;
                GetSweepTime(out res);
                return res;                
            }
            set
            {
                SetSweepTime(value);
            }
        }

        #endregion
                
        #region IIviRFSigGenSweep Members

        void IIviRFSigGenSweep.Configure(IviRFSigGenSweepModeEnum Mode, IviRFSigGenSweepTriggerSourceEnum TriggerSource)
        {
            this.Sweep.Mode = Mode;
            switch (TriggerSource)
            {
                case IviRFSigGenSweepTriggerSourceEnum.IviRFSigGenSweepTriggerSourceImmediate:
                    SetSweepContinuousMode(true);
                    EnableSweep();
                    break;
                default:
                    throw new ArgumentException("Not Implemented!");                   
            }
        }

        IIviRFSigGenFrequencyStep IIviRFSigGenSweep.FrequencyStep
        {
            get { throw new NotImplementedException(); }
        }

        IIviRFSigGenFrequencySweep IIviRFSigGenSweep.FrequencySweep
        {
            get { return (IIviRFSigGenFrequencySweep)this; }
        }

        IIviRFSigGenList IIviRFSigGenSweep.List
        {
            get { throw new NotImplementedException(); }
        }

        IviRFSigGenSweepModeEnum IIviRFSigGenSweep.Mode
        {
            get
            {
                short res;
                GetFreqSweepMode(out res);
                switch (res)
                {
                    case hp836xxConstants.FreqSweepModeCw:
                        return IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeNone;                        
                    case hp836xxConstants.FreqSweepModeList:
                        return IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeList;                       
                    case hp836xxConstants.FreqSweepModeRamp:
                        return IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeFrequencySweep;                        
                    case hp836xxConstants.FreqSweepModeStep:
                        return IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeFrequencyStep;                        
                    default:
                        throw new Exception("Sweeping mode not recognized!");
                        
                }
            }
            set
            {
                switch (value)
                {
                    case IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeNone:
                        SetFreqSweepMode(hp836xxConstants.FreqSweepModeCw);
                        break;
                    case IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeFrequencyStep:
                        SetFreqSweepMode(hp836xxConstants.FreqSweepModeStep);
                        break;
                    case IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeList:
                        SetFreqSweepMode(hp836xxConstants.FreqSweepModeList);
                        break;
                    case IviRFSigGenSweepModeEnum.IviRFSigGenSweepModeFrequencySweep:
                        SetFreqSweepMode(hp836xxConstants.FreqSweepModeRamp);
                        break;
                    default:
                        throw new ArgumentException("Not implemented!");
                }
            }
        }

        IIviRFSigGenPowerStep IIviRFSigGenSweep.PowerStep
        {
            get { throw new NotImplementedException(); }
        }

       IIviRFSigGenPowerSweep IIviRFSigGenSweep.PowerSweep
        {
            get { throw new NotImplementedException(); }
        }

        IviRFSigGenSweepTriggerSourceEnum IIviRFSigGenSweep.TriggerSource
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

        #region IIviRFSigGenALC Members

        double IIviRFSigGenALC.Bandwidth
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        void IIviRFSigGenALC.Configure(IviRFSigGenALCSourceEnum Source, double Bandwidth)
        {
            throw new NotImplementedException();
        }

        bool IIviRFSigGenALC.Enabled
        {
            get
            {
                bool res;
                GetAmplitudeAttenuationAuto(out res);
                return res;
            }
            set
            {
                SetAmplitudeAttenuationAuto(value);
            }
        }

        IviRFSigGenALCSourceEnum IIviRFSigGenALC.Source
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }

    public class hp836xxConstants
    {

        public const short FreqSweepModeCw = 0;

        public const short FreqSweepModeRamp = 1;

        public const short FreqSweepModeStep = 2;

        public const short FreqSweepModeList = 3;
    }
}
